/*
 * Copyright 2012 Daniel Kurka
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.googlecode.mgwt.examples.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;
import com.googlecode.mgwt.mvp.client.Animation;
import com.googlecode.mgwt.ui.client.MGWT;
import com.googlecode.mgwt.ui.client.MGWTSettings;
import com.googlecode.mgwt.ui.client.animation.AnimationHelper;
import com.googlecode.mgwt.ui.client.widget.Carousel;
import com.googlecode.mgwt.ui.client.widget.LayoutPanel;
import com.googlecode.mgwt.ui.client.widget.RoundPanel;
import com.googlecode.mgwt.ui.client.widget.ScrollPanel;

public class SwipePanelExample implements EntryPoint {

	@Override
	public void onModuleLoad() {
		//set viewport and other settings for mobile
		MGWT.applySettings(MGWTSettings.getAppSetting());

		//build animation helper and attach it
		AnimationHelper animationHelper = new AnimationHelper();
		RootPanel.get().add(animationHelper);

		//build some UI
		LayoutPanel layoutPanel = new LayoutPanel();

		//build carousel widget
		Carousel carousel = new Carousel();
		layoutPanel.add(carousel);

		//build 5 slides
		for (int i = 0; i < 5; i++) {

			ScrollPanel scrollPanel = new ScrollPanel();
			scrollPanel.setScrollingEnabledX(false);

			RoundPanel flowPanel3 = new RoundPanel();
			//put in some content
			for (int j = 0; j < 10; j++) {
				HTML html = new HTML("Slide: " + (i + 1));
				html.getElement().getStyle().setMarginBottom(300, Unit.PX);
				flowPanel3.add(html);
			}

			scrollPanel.setWidget(flowPanel3);

			carousel.add(scrollPanel);
		}

		//animate
		animationHelper.goTo(layoutPanel, Animation.SLIDE);
	}

}
